<?php
declare(strict_types=1);

namespace Service\CountryService;

use Service\BaseService;
use Service\Code\Normal;
use App\Model\BbcModel\Country;
use Service\CacheService\CacheProviderService as Cache;
use Hyperf\HttpServer\Contract\RequestInterface;

/**
 * 商品国家
 * @author hj
 */
class CountryService extends BaseService {

    /**
     * 所有国家
     */
    public static function getCountry() {
        $cache_key = 'Country_GetCountry';
        $countries = Cache::getCacheByKey($cache_key);

        if (empty($countries)) {
            $countries = Country::where('df', 0)->get()->toArray();
            $countries = array_column($countries, null, 'id');
            Cache::cacheBySetKeyValue($cache_key, $countries, 3600);
        }
        return $countries;
    }
}